<!DOCTYPE html>
<html>
<!-- Created by GNU Texinfo 7.1.1, https://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!-- This file documents the use of the GNU compilers.

Copyright © 1988-2023 Free Software Foundation, Inc.

Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with the
Invariant Sections being "Funding Free Software", the Front-Cover
Texts being (a) (see below), and with the Back-Cover Texts being (b)
(see below).  A copy of the license is included in the section entitled
"GNU Free Documentation License".

(a) The FSF's Front-Cover Text is:

A GNU Manual

(b) The FSF's Back-Cover Text is:

You have freedom to copy and modify this GNU Manual, like GNU
     software.  Copies published by the Free Software Foundation raise
     funds for GNU development. -->
<title>Type Traits (Using the GNU Compiler Collection (GCC))</title>

<meta name="description" content="Type Traits (Using the GNU Compiler Collection (GCC))">
<meta name="keywords" content="Type Traits (Using the GNU Compiler Collection (GCC))">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta name="viewport" content="width=device-width,initial-scale=1">

<link href="index.html" rel="start" title="Top">
<link href="Indices.html" rel="index" title="Indices">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="C_002b_002b-Extensions.html" rel="up" title="C++ Extensions">
<link href="C_002b_002b-Concepts.html" rel="next" title="C++ Concepts">
<link href="Function-Multiversioning.html" rel="prev" title="Function Multiversioning">
<style type="text/css">
<!--
a.copiable-link {visibility: hidden; text-decoration: none; line-height: 0em}
kbd.key {font-style: normal}
span:hover a.copiable-link {visibility: visible}
strong.def-name {font-family: monospace; font-weight: bold; font-size: larger}
-->
</style>


</head>

<body lang="en_US">
<div class="section-level-extent" id="Type-Traits">
<div class="nav-panel">
<p>
Next: <a href="C_002b_002b-Concepts.html" accesskey="n" rel="next">C++ Concepts</a>, Previous: <a href="Function-Multiversioning.html" accesskey="p" rel="prev">Function Multiversioning</a>, Up: <a href="C_002b_002b-Extensions.html" accesskey="u" rel="up">Extensions to the C++ Language</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Indices.html" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<h3 class="section" id="Type-Traits-1"><span>7.9 Type Traits<a class="copiable-link" href="#Type-Traits-1"> &para;</a></span></h3>

<p>The C++ front end implements syntactic extensions that allow
compile-time determination of 
various characteristics of a type (or of a
pair of types).
</p>
<dl class="first-deftypefn">
<dt class="deftypefn" id="index-_005f_005fhas_005fnothrow_005fassign"><span class="category-def">Built-in Function: </span><span><code class="def-type">bool</code> <strong class="def-name">__has_nothrow_assign</strong> <code class="def-code-arguments">(<var class="var">type</var>)</code><a class="copiable-link" href="#index-_005f_005fhas_005fnothrow_005fassign"> &para;</a></span></dt>
<dd><p>If <var class="var">type</var> is <code class="code">const</code>-qualified or is a reference type then
the trait is <code class="code">false</code>.  Otherwise if <code class="code">__has_trivial_assign (type)</code>
is <code class="code">true</code> then the trait is <code class="code">true</code>, else if <var class="var">type</var> is
a cv-qualified class or union type with copy assignment operators that are
known not to throw an exception then the trait is <code class="code">true</code>, else it is
<code class="code">false</code>.
Requires: <var class="var">type</var> shall be a complete type, (possibly cv-qualified)
<code class="code">void</code>, or an array of unknown bound.
</p></dd></dl>

<dl class="first-deftypefn">
<dt class="deftypefn" id="index-_005f_005fhas_005fnothrow_005fcopy"><span class="category-def">Built-in Function: </span><span><code class="def-type">bool</code> <strong class="def-name">__has_nothrow_copy</strong> <code class="def-code-arguments">(<var class="var">type</var>)</code><a class="copiable-link" href="#index-_005f_005fhas_005fnothrow_005fcopy"> &para;</a></span></dt>
<dd><p>If <code class="code">__has_trivial_copy (type)</code> is <code class="code">true</code> then the trait is
<code class="code">true</code>, else if <var class="var">type</var> is a cv-qualified class or union type
with copy constructors that are known not to throw an exception then
the trait is <code class="code">true</code>, else it is <code class="code">false</code>.
Requires: <var class="var">type</var> shall be a complete type, (possibly cv-qualified)
<code class="code">void</code>, or an array of unknown bound.
</p></dd></dl>

<dl class="first-deftypefn">
<dt class="deftypefn" id="index-_005f_005fhas_005fnothrow_005fconstructor"><span class="category-def">Built-in Function: </span><span><code class="def-type">bool</code> <strong class="def-name">__has_nothrow_constructor</strong> <code class="def-code-arguments">(<var class="var">type</var>)</code><a class="copiable-link" href="#index-_005f_005fhas_005fnothrow_005fconstructor"> &para;</a></span></dt>
<dd><p>If <code class="code">__has_trivial_constructor (type)</code> is <code class="code">true</code> then the trait
is <code class="code">true</code>, else if <var class="var">type</var> is a cv class or union type (or array
thereof) with a default constructor that is known not to throw an
exception then the trait is <code class="code">true</code>, else it is <code class="code">false</code>.
Requires: <var class="var">type</var> shall be a complete type, (possibly cv-qualified)
<code class="code">void</code>, or an array of unknown bound.
</p></dd></dl>

<dl class="first-deftypefn">
<dt class="deftypefn" id="index-_005f_005fhas_005ftrivial_005fassign"><span class="category-def">Built-in Function: </span><span><code class="def-type">bool</code> <strong class="def-name">__has_trivial_assign</strong> <code class="def-code-arguments">(<var class="var">type</var>)</code><a class="copiable-link" href="#index-_005f_005fhas_005ftrivial_005fassign"> &para;</a></span></dt>
<dd><p>If <var class="var">type</var> is <code class="code">const</code>- qualified or is a reference type then
the trait is <code class="code">false</code>.  Otherwise if <code class="code">__is_trivial (type)</code> is
<code class="code">true</code> then the trait is <code class="code">true</code>, else if <var class="var">type</var> is
a cv-qualified class or union type with a trivial copy assignment
([class.copy]) then the trait is <code class="code">true</code>, else it is <code class="code">false</code>.
Requires: <var class="var">type</var> shall be a complete type, (possibly cv-qualified)
<code class="code">void</code>, or an array of unknown bound.
</p></dd></dl>

<dl class="first-deftypefn">
<dt class="deftypefn" id="index-_005f_005fhas_005ftrivial_005fcopy"><span class="category-def">Built-in Function: </span><span><code class="def-type">bool</code> <strong class="def-name">__has_trivial_copy</strong> <code class="def-code-arguments">(<var class="var">type</var>)</code><a class="copiable-link" href="#index-_005f_005fhas_005ftrivial_005fcopy"> &para;</a></span></dt>
<dd><p>If <code class="code">__is_trivial (type)</code> is <code class="code">true</code> or <var class="var">type</var> is a reference
type then the trait is <code class="code">true</code>, else if <var class="var">type</var> is a cv class
or union type with a trivial copy constructor ([class.copy]) then the trait
is <code class="code">true</code>, else it is <code class="code">false</code>.  Requires: <var class="var">type</var> shall be
a complete type, (possibly cv-qualified) <code class="code">void</code>, or an array of unknown
bound.
</p></dd></dl>

<dl class="first-deftypefn">
<dt class="deftypefn" id="index-_005f_005fhas_005ftrivial_005fconstructor"><span class="category-def">Built-in Function: </span><span><code class="def-type">bool</code> <strong class="def-name">__has_trivial_constructor</strong> <code class="def-code-arguments">(<var class="var">type</var>)</code><a class="copiable-link" href="#index-_005f_005fhas_005ftrivial_005fconstructor"> &para;</a></span></dt>
<dd><p>If <code class="code">__is_trivial (type)</code> is <code class="code">true</code> then the trait is <code class="code">true</code>,
else if <var class="var">type</var> is a cv-qualified class or union type (or array thereof)
with a trivial default constructor ([class.ctor]) then the trait is <code class="code">true</code>,
else it is <code class="code">false</code>.
Requires: <var class="var">type</var> shall be a complete type, (possibly cv-qualified)
<code class="code">void</code>, or an array of unknown bound.
</p></dd></dl>

<dl class="first-deftypefn">
<dt class="deftypefn" id="index-_005f_005fhas_005ftrivial_005fdestructor"><span class="category-def">Built-in Function: </span><span><code class="def-type">bool</code> <strong class="def-name">__has_trivial_destructor</strong> <code class="def-code-arguments">(<var class="var">type</var>)</code><a class="copiable-link" href="#index-_005f_005fhas_005ftrivial_005fdestructor"> &para;</a></span></dt>
<dd><p>If <code class="code">__is_trivial (type)</code> is <code class="code">true</code> or <var class="var">type</var> is a reference type
then the trait is <code class="code">true</code>, else if <var class="var">type</var> is a cv class or union
type (or array thereof) with a trivial destructor ([class.dtor]) then
the trait is <code class="code">true</code>, else it is <code class="code">false</code>.
Requires: <var class="var">type</var> shall be a complete type, (possibly cv-qualified)
<code class="code">void</code>, or an array of unknown bound.
</p></dd></dl>

<dl class="first-deftypefn">
<dt class="deftypefn" id="index-_005f_005fhas_005fvirtual_005fdestructor"><span class="category-def">Built-in Function: </span><span><code class="def-type">bool</code> <strong class="def-name">__has_virtual_destructor</strong> <code class="def-code-arguments">(<var class="var">type</var>)</code><a class="copiable-link" href="#index-_005f_005fhas_005fvirtual_005fdestructor"> &para;</a></span></dt>
<dd><p>If <var class="var">type</var> is a class type with a virtual destructor
([class.dtor]) then the trait is <code class="code">true</code>, else it is <code class="code">false</code>.
Requires: If <var class="var">type</var> is a non-union class type, it shall be a complete type.
</p></dd></dl>

<dl class="first-deftypefn">
<dt class="deftypefn" id="index-_005f_005fis_005fabstract"><span class="category-def">Built-in Function: </span><span><code class="def-type">bool</code> <strong class="def-name">__is_abstract</strong> <code class="def-code-arguments">(<var class="var">type</var>)</code><a class="copiable-link" href="#index-_005f_005fis_005fabstract"> &para;</a></span></dt>
<dd><p>If <var class="var">type</var> is an abstract class ([class.abstract]) then the trait
is <code class="code">true</code>, else it is <code class="code">false</code>.
Requires: If <var class="var">type</var> is a non-union class type, it shall be a complete type.
</p></dd></dl>

<dl class="first-deftypefn">
<dt class="deftypefn" id="index-_005f_005fis_005faggregate"><span class="category-def">Built-in Function: </span><span><code class="def-type">bool</code> <strong class="def-name">__is_aggregate</strong> <code class="def-code-arguments">(<var class="var">type</var>)</code><a class="copiable-link" href="#index-_005f_005fis_005faggregate"> &para;</a></span></dt>
<dd><p>If <var class="var">type</var> is an aggregate type ([dcl.init.aggr]) the trait is
<code class="code">true</code>, else it is <code class="code">false</code>.
Requires: If <var class="var">type</var> is a class type, it shall be a complete type.
</p></dd></dl>

<dl class="first-deftypefn">
<dt class="deftypefn" id="index-_005f_005fis_005fbase_005fof"><span class="category-def">Built-in Function: </span><span><code class="def-type">bool</code> <strong class="def-name">__is_base_of</strong> <code class="def-code-arguments">(<var class="var">base_type</var>, <var class="var">derived_type</var>)</code><a class="copiable-link" href="#index-_005f_005fis_005fbase_005fof"> &para;</a></span></dt>
<dd><p>If <var class="var">base_type</var> is a base class of <var class="var">derived_type</var>
([class.derived]) then the trait is <code class="code">true</code>, otherwise it is <code class="code">false</code>.
Top-level cv-qualifications of <var class="var">base_type</var> and
<var class="var">derived_type</var> are ignored.  For the purposes of this trait, a
class type is considered is own base.
Requires: if <code class="code">__is_class (base_type)</code> and <code class="code">__is_class (derived_type)</code>
are <code class="code">true</code> and <var class="var">base_type</var> and <var class="var">derived_type</var> are not the same
type (disregarding cv-qualifiers), <var class="var">derived_type</var> shall be a complete
type.  A diagnostic is produced if this requirement is not met.
</p></dd></dl>

<dl class="first-deftypefn">
<dt class="deftypefn" id="index-_005f_005fis_005fclass"><span class="category-def">Built-in Function: </span><span><code class="def-type">bool</code> <strong class="def-name">__is_class</strong> <code class="def-code-arguments">(<var class="var">type</var>)</code><a class="copiable-link" href="#index-_005f_005fis_005fclass"> &para;</a></span></dt>
<dd><p>If <var class="var">type</var> is a cv-qualified class type, and not a union type
([basic.compound]) the trait is <code class="code">true</code>, else it is <code class="code">false</code>.
</p></dd></dl>


<dl class="first-deftypefn">
<dt class="deftypefn" id="index-_005f_005fis_005fempty"><span class="category-def">Built-in Function: </span><span><code class="def-type">bool</code> <strong class="def-name">__is_empty</strong> <code class="def-code-arguments">(<var class="var">type</var>)</code><a class="copiable-link" href="#index-_005f_005fis_005fempty"> &para;</a></span></dt>
<dd><p>If <code class="code">__is_class (type)</code> is <code class="code">false</code> then the trait is <code class="code">false</code>.
Otherwise <var class="var">type</var> is considered empty if and only if: <var class="var">type</var>
has no non-static data members, or all non-static data members, if
any, are bit-fields of length 0, and <var class="var">type</var> has no virtual
members, and <var class="var">type</var> has no virtual base classes, and <var class="var">type</var>
has no base classes <var class="var">base_type</var> for which
<code class="code">__is_empty (base_type)</code> is <code class="code">false</code>.
Requires: If <var class="var">type</var> is a non-union class type, it shall be a complete type.
</p></dd></dl>

<dl class="first-deftypefn">
<dt class="deftypefn" id="index-_005f_005fis_005fenum"><span class="category-def">Built-in Function: </span><span><code class="def-type">bool</code> <strong class="def-name">__is_enum</strong> <code class="def-code-arguments">(<var class="var">type</var>)</code><a class="copiable-link" href="#index-_005f_005fis_005fenum"> &para;</a></span></dt>
<dd><p>If <var class="var">type</var> is a cv enumeration type ([basic.compound]) the trait is
<code class="code">true</code>, else it is <code class="code">false</code>.
</p></dd></dl>

<dl class="first-deftypefn">
<dt class="deftypefn" id="index-_005f_005fis_005ffinal"><span class="category-def">Built-in Function: </span><span><code class="def-type">bool</code> <strong class="def-name">__is_final</strong> <code class="def-code-arguments">(<var class="var">type</var>)</code><a class="copiable-link" href="#index-_005f_005fis_005ffinal"> &para;</a></span></dt>
<dd><p>If <var class="var">type</var> is a class or union type marked <code class="code">final</code>, then the trait
is <code class="code">true</code>, else it is <code class="code">false</code>.
Requires: If <var class="var">type</var> is a class type, it shall be a complete type.
</p></dd></dl>

<dl class="first-deftypefn">
<dt class="deftypefn" id="index-_005f_005fis_005fliteral_005ftype"><span class="category-def">Built-in Function: </span><span><code class="def-type">bool</code> <strong class="def-name">__is_literal_type</strong> <code class="def-code-arguments">(<var class="var">type</var>)</code><a class="copiable-link" href="#index-_005f_005fis_005fliteral_005ftype"> &para;</a></span></dt>
<dd><p>If <var class="var">type</var> is a literal type ([basic.types]) the trait is
<code class="code">true</code>, else it is <code class="code">false</code>.
Requires: <var class="var">type</var> shall be a complete type, (possibly cv-qualified)
<code class="code">void</code>, or an array of unknown bound.
</p></dd></dl>

<dl class="first-deftypefn">
<dt class="deftypefn" id="index-_005f_005fis_005fpod"><span class="category-def">Built-in Function: </span><span><code class="def-type">bool</code> <strong class="def-name">__is_pod</strong> <code class="def-code-arguments">(<var class="var">type</var>)</code><a class="copiable-link" href="#index-_005f_005fis_005fpod"> &para;</a></span></dt>
<dd><p>If <var class="var">type</var> is a cv POD type ([basic.types]) then the trait is <code class="code">true</code>,
else it is <code class="code">false</code>.
Requires: <var class="var">type</var> shall be a complete type, (possibly cv-qualified)
<code class="code">void</code>, or an array of unknown bound.
</p></dd></dl>

<dl class="first-deftypefn">
<dt class="deftypefn" id="index-_005f_005fis_005fpolymorphic"><span class="category-def">Built-in Function: </span><span><code class="def-type">bool</code> <strong class="def-name">__is_polymorphic</strong> <code class="def-code-arguments">(<var class="var">type</var>)</code><a class="copiable-link" href="#index-_005f_005fis_005fpolymorphic"> &para;</a></span></dt>
<dd><p>If <var class="var">type</var> is a polymorphic class ([class.virtual]) then the trait
is <code class="code">true</code>, else it is <code class="code">false</code>.
Requires: If <var class="var">type</var> is a non-union class type, it shall be a complete type.
</p></dd></dl>

<dl class="first-deftypefn">
<dt class="deftypefn" id="index-_005f_005fis_005fstandard_005flayout"><span class="category-def">Built-in Function: </span><span><code class="def-type">bool</code> <strong class="def-name">__is_standard_layout</strong> <code class="def-code-arguments">(<var class="var">type</var>)</code><a class="copiable-link" href="#index-_005f_005fis_005fstandard_005flayout"> &para;</a></span></dt>
<dd><p>If <var class="var">type</var> is a standard-layout type ([basic.types]) the trait is
<code class="code">true</code>, else it is <code class="code">false</code>.
Requires: <var class="var">type</var> shall be a complete type, an array of complete types,
or (possibly cv-qualified) <code class="code">void</code>.
</p></dd></dl>

<dl class="first-deftypefn">
<dt class="deftypefn" id="index-_005f_005fis_005ftrivial"><span class="category-def">Built-in Function: </span><span><code class="def-type">bool</code> <strong class="def-name">__is_trivial</strong> <code class="def-code-arguments">(<var class="var">type</var>)</code><a class="copiable-link" href="#index-_005f_005fis_005ftrivial"> &para;</a></span></dt>
<dd><p>If <var class="var">type</var> is a trivial type ([basic.types]) the trait is
<code class="code">true</code>, else it is <code class="code">false</code>.
Requires: <var class="var">type</var> shall be a complete type, an array of complete types,
or (possibly cv-qualified) <code class="code">void</code>.
</p></dd></dl>

<dl class="first-deftypefn">
<dt class="deftypefn" id="index-_005f_005fis_005funion"><span class="category-def">Built-in Function: </span><span><code class="def-type">bool</code> <strong class="def-name">__is_union</strong> <code class="def-code-arguments">(<var class="var">type</var>)</code><a class="copiable-link" href="#index-_005f_005fis_005funion"> &para;</a></span></dt>
<dd><p>If <var class="var">type</var> is a cv union type ([basic.compound]) the trait is
<code class="code">true</code>, else it is <code class="code">false</code>.
</p></dd></dl>

<dl class="first-deftypefn">
<dt class="deftypefn" id="index-_005f_005funderlying_005ftype"><span class="category-def">Built-in Function: </span><span><code class="def-type">bool</code> <strong class="def-name">__underlying_type</strong> <code class="def-code-arguments">(<var class="var">type</var>)</code><a class="copiable-link" href="#index-_005f_005funderlying_005ftype"> &para;</a></span></dt>
<dd><p>The underlying type of <var class="var">type</var>.
Requires: <var class="var">type</var> shall be an enumeration type ([dcl.enum]).
</p></dd></dl>

<dl class="first-deftypefn">
<dt class="deftypefn" id="index-_005f_005finteger_005fpack"><span class="category-def">Built-in Function: </span><span><code class="def-type">bool</code> <strong class="def-name">__integer_pack</strong> <code class="def-code-arguments">(<var class="var">length</var>)</code><a class="copiable-link" href="#index-_005f_005finteger_005fpack"> &para;</a></span></dt>
<dd><p>When used as the pattern of a pack expansion within a template
definition, expands to a template argument pack containing integers
from <code class="code">0</code> to <code class="code"><var class="var">length</var>-1</code>.  This is provided for
efficient implementation of <code class="code">std::make_integer_sequence</code>.
</p></dd></dl>


</div>
<hr>
<div class="nav-panel">
<p>
Next: <a href="C_002b_002b-Concepts.html">C++ Concepts</a>, Previous: <a href="Function-Multiversioning.html">Function Multiversioning</a>, Up: <a href="C_002b_002b-Extensions.html">Extensions to the C++ Language</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Indices.html" title="Index" rel="index">Index</a>]</p>
</div>



</body>
</html>
